<?php
/**
 * BootAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using BootAdmin.
 *
 * @Author G.r<root@BootAdmin.com>
 */

declare (strict_types=1);

namespace app\admin\controller\system;

use app\admin\Base;
use app\admin\logic\FileLogic;
use app\admin\validate\FileValidate;

/**
 * 文件控制器
 */
class File extends Base
{
    protected FileLogic $logic;

    protected FileValidate $validate;

    /**
     * 初始化
     */
    public function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub
        $this->logic = new FileLogic();
        $this->validate = new FileValidate();
    }

    /**
     * 列表
     */
    public function list()
    {
        $params = $this->validate->go();
        return $this->dataLists($this->logic->list($params));
    }

    /**
     * 列表
     */
    public function listCate()
    {
        $params = $this->validate->go();
        return $this->dataLists($this->logic->listCate($params));
    }

    /**
     * 文件移动
     */
    public function move()
    {
        $params = $this->validate->post()->goCheck('move');
        $this->logic->move($params);
        return $this->success('移动成功');
    }


    /**
     * 重命名文件
     */
    public function rename()
    {
        $params = $this->validate->post()->goCheck('rename');
        $this->logic->rename($params);
        return $this->success('重命名成功');
    }


    /**
     * 删除文件
     */
    public function delete()
    {
        $params = $this->validate->post()->goCheck('delete');
        $this->logic->del($params);
        return $this->success('删除成功');
    }


    /**
     * 添加文件分类
     */
    public function addCate()
    {
        $params = $this->validate->post()->goCheck('addCate');
        $this->logic->addCate($params);
        return $this->success('添加成功', [], 1, 1);
    }


    /**
     * 编辑文件分类
     */
    public function editCate()
    {
        $params = $this->validate->post()->goCheck('editCate');
        $this->logic->editCate($params);
        return $this->success('编辑成功');
    }


    /**
     * 删除文件分类
     */
    public function delCate()
    {
        $params = $this->validate->post()->goCheck('id');
        $this->logic->delCate($params);
        return $this->success('删除成功');
    }
}